﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.OracleClient;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;

namespace Logistics.DataAccess
{
    public class TC_OWW_FILE
    {
        public bool Add(Model.TC_OWW_FILE model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO TC_OWW_FILE(");
            strSql.Append("TC_OWW000,");
            strSql.Append("TC_OWW001,");
            strSql.Append("TC_OWW002,");
            strSql.Append("TC_OWW003,");
            strSql.Append("TC_OWW004)");
            strSql.Append(" VALUES (");
            strSql.Append("@in_TC_OWW000,");
            strSql.Append("@in_TC_OWW001,");
            strSql.Append("@in_TC_OWW002,");
            strSql.Append("@in_TC_OWW003,");
            strSql.Append("@in_TC_OWW004)");
            OracleParameter[] cmdParms = {
                DBHelper.CreateDbParameter("@in_TC_OWW000", DbType.String,20 ,DBValue.GetDBValue(model.TC_OWW000)),
                DBHelper.CreateDbParameter("@in_TC_OWW001", DbType.String,20 ,DBValue.GetDBValue(model.TC_OWW001)),
                DBHelper.CreateDbParameter("@in_TC_OWW002", DbType.String,20 ,DBValue.GetDBValue(model.TC_OWW002)),
                DBHelper.CreateDbParameter("@in_TC_OWW003", DbType.String,20 ,DBValue.GetDBValue(model.TC_OWW003)),
                DBHelper.CreateDbParameter("@in_TC_OWW004", DbType.String,20 ,DBValue.GetDBValue(model.TC_OWW004)),
            };

            return DBHelper.ExecuteSql(strSql.ToString(), cmdParms) > 0;
        }

      
        #region 
        /// <summary>
        /// 由一行数据得到一个实体
        /// </summary>
        private Model.TC_OWW_FILE GetModel(DbDataReader dr)
        {
            Model.TC_OWW_FILE model = new Model.TC_OWW_FILE();
            model.TC_OWW001 = DBHelper.GetString(dr["TC_OWW001"]);
            model.TC_OWW002 = DBHelper.GetString(dr["TC_OWW002"]);
            model.TC_OWW003 = DBHelper.GetString(dr["TC_OWW003"]);
            model.TC_OWW004 = DBHelper.GetString(dr["TC_OWW004"]);
            return model;
        }

        /// <summary>
        /// 由DbDataReader得到泛型数据列表
        /// </summary>
        private List<Model.TC_OWW_FILE> GetList(DbDataReader dr)
        {
            List<Model.TC_OWW_FILE> lst = new List<Model.TC_OWW_FILE>();
            while (dr.Read())
            {
                lst.Add(GetModel(dr));
            }
            return lst;
        }
        #endregion
    }
}
